<include file="Index:header" />
<link href="__PUBLIC__/asset/css/star-rating.css" media="all" rel="stylesheet" type="text/css"/>
<script src="__PUBLIC__/asset/js/star-rating.js" type="text/javascript"></script>

<style>
    .my-cursor{
        cursor: pointer;
        margin: 3px;
    }
    .form-group{
        padding:15px;
    }
</style>
<div class="panel panel-primary" style="float:left;width:18%;height:620px">
    <div class="panel-heading">导航条</div>
    <div class="panel-body">
        <ul class="nav nav-pills nav-stacked" role="tablist">
            <li role="presentation"><a href="__APP__/Student/profile">个人中心</a></li>
            <li role="presentation" class="active"><a href="__APP__/TeachReview/reviewlist">教学评价</a></li>
            <li role="presentation"><a href="__APP__/Student/passwd">修改密码</a></li>
            <li role="presentation"><a href="__APP__/Public/loginout">退出系统</a></li>
        </ul>
    </div>
</div>
<div class="panel panel-primary" style="float:left;width:81%;margin-left:1%;height:620px">
    <div class="panel-heading" style="text-align: center">
        <h3 onclick="javascript:window.location.href = '__APP__/TeachReview/reviewlist'" class="glyphicon glyphicon-chevron-left panel-title" style="float:left;cursor: pointer">教学评价</h3> <font style="font-size: 16px;">{$title}</font>
    </div>
    <div class="panel-body">
        <!--评价星级-->
        <div style="width:80%;margin: 0 auto">
            <div class="form-group">
                <label class="control-label">教学星级</label>
                <input id="input-21f" value="0" type="number" class="rating" min=0 max=5 step=0.5 data-size="lg">
                <label class="control-lable">分数</label>
            </div>
            <div class="form-group">
                <label class="control-label">教学标签</label>
                <div style="width:100%;">
                    <volist name="label_list" id="label" >
                        <span class="my-review-lable label label-default my-cursor" lable_id="{$label.lable_id}" >{$label.lable_name}</span>
                    </volist>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">教学意见</label>
                <textarea class="form-control review_note" placeholder="请输入教学修改意见" rows="3" ></textarea>
            </div>
            <div class="form-group">
                <button type="button" class="submit-review btn btn-primary">确认评价</button>
            </div>
        </div>
    </div>
</div>

<script>
    jQuery(document).ready(function () {
        $(".rating-kv").rating();
        //动态加载数据
        //点击事件
        $(".my-review-lable").click(function () {
            if (!$(this).hasClass("label-warning")) {
                $(this).addClass("label-warning")
            } else {
                $(this).removeClass("label-warning")
            }
        });

        //提交表单数据
        $(".submit-review").click(function () {
            var id = {$review_info_id};
            var reviewNote = $(".review_note").val();
            //获取分数
            var rating = $(".rating").val();
          
            if(rating<=0||rating==''){
                alert("请评分");return;
            }
            if(reviewNote==''){
                alert("请输入教学意见");return;
            }
            var lableId = [];
            $(".my-review-lable").each(function (n,ele) {
                if($(ele).hasClass("label-warning")){
                   lableId.push($(ele).attr("lable_id"));
                }
            });
            lableId = lableId.join(",");
            var url = '__APP__'+"TeachReview/studentreview";
            $.post(url,{"reviewNote":reviewNote,"lableId":lableId,"rating":rating,"review_info_id":id},function(data){
                if(data.success==true){
                    alert("评价成功");
                    window.location.href = '__APP__'+"/TeachReview/reviewlist";
                }else{
                    alert(data.msg);
                }
            });
        });
    });
</script>
<include file="Index:footer" />
